<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta name="author" content="Ionel Alexandru">
	<meta name="reply-to" content="ionel.alexandru@gmail.com">
	<title>fMath Editor - www.fmath.info</title>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
	<table width="810" height="460">
	<tr height="100%">
		<td align="center">
		<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="800" height="460" id="editML" name="editML" align="middle">
			<param name=wmode value="transparent">
			<param name="allowScriptAccess" value="always"/>
			<param name="allowFullScreen" value="true"/>
			<param name="loop" value="false"/>
			<param name="quality" value="high" />
			<param name="flashVars" value="configUrl=configMathMLEditor.xml"/>
			<param name="movie" value="mathml/MathMLEditor.swf?configUrl=configMathMLEditor.xml" />
			<embed src="mathml/MathMLEditor.swf?configUrl=configMathMLEditor.xml"
	            wmode="transparent"
				flashVars="configUrl=configMathMLEditor.xml"
				loop="false"
				quality="high"
				width="800"
				height="460"
                id="editML"
				name="editML"
				align="middle"
                swliveconnect="true"
				allowScriptAccess="always"
				allowFullScreen="true"
				type="application/x-shockwave-flash"
				pluginspage="http://www.adobe.com/go/getflashplayer" />
		</object>
		</td>
	</tr>
	</table>

<script>

	function getMathMLFromJavascript(name){
		var mathml = parent.CKEDITOR.plugins.get('fmath_formula').getCurrentMathML();
		if(mathml==null){
			mathml = "<mrow><mtext>...</mtext></mrow>";
		}
		document.getElementById('editML').focus();
		return mathml;
	}

	function setMathMLToEditor(mathml){
		getSWF("editML").setMathML(mathml);
	}


	function getMathMLFromEditor(){
		return getSWF("editML").getMathML();
	}

	var ed;
	var name;
	function saveImage(editor){
		ed = editor;
		getSWF("editML").saveImageOnServer();
	}

	function setFileNameFromServer(n){
		name = n;
		setTimeout('saveAndUpdate()', 10);
	}


	function saveAndUpdate(){
			var mathml = getMathMLFromEditor();
			var newId = parent.CKEDITOR.plugins.get('fmath_formula').addMathML(mathml);

			ed.insertHtml("<img src='"+name+"' border='0' id='"+newId+"' />");

			var dialog = parent.CKEDITOR.dialog.getCurrent();
			dialog.hide();

	}

	function getSWF(movieName) {
	    if (navigator.appName.indexOf("Microsoft") != -1) {
	        return document.getElementById(movieName);
	    }
	    else {
	      if(document[movieName].length != undefined){
	          return document[movieName][1];
	      }
	        return document[movieName];
	    }
	}




</script>

</body>
</html>
